package com.wicket.okrcomponent.biz.service.nb;

import cn.hutool.core.bean.BeanUtil;
import com.wicket.okrcomponent.biz.service.dto.common.DataSetsListOneDto;
import org.apache.skywalking.apm.toolkit.trace.Tag;
import org.apache.skywalking.apm.toolkit.trace.Tags;
import org.apache.skywalking.apm.toolkit.trace.Trace;
import org.springframework.stereotype.Service;
import com.wicket.okrcomponent.biz.service.dto.req.ImplementSmartSessionReceiveFieldInputReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementSmartSessionReceiveFieldInputRespDto;
import com.wicket.okrcomponent.biz.service.dto.req.ObtainQuantitativeScoreForAchievementLevelCalcReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ObtainQuantitativeScoreForAchievementLevelCalcRespDto;
import com.wicket.okrcomponent.biz.service.dto.req.ImplementTenReceivingFieldReqDto;
import com.wicket.okrcomponent.biz.service.dto.res.ImplementTenReceivingFieldRespDto;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

/**
 * @author ： 手工接入方法
 * @since 2022/5/28 15:32
 *
 *
 * @version 1.0
 */
@Service
public class NbTargetCalc {
/**
      * code:receptionService
      * name:M2接收入参字段
      * desc:undefined
      * gen by moon at 3/24/2024, 4:32:51 AM
      * 
      **/
     @Trace(operationName = "M2接收入参字段")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementSmartSessionReceiveFieldInputRespDto implementSmartSessionReceiveFieldInput(ImplementSmartSessionReceiveFieldInputReqDto reqDto) {
         return BeanUtil.toBean(reqDto,ImplementSmartSessionReceiveFieldInputRespDto.class);
      }
/**
      * code:quantitativeScoreForAchievementLevelCalc
      * name:M2获取成果等级转量化得分
      * desc:undefined
      * gen by moon at 4/25/2024, 1:48:46 PM
      *
      **/
     @Trace(operationName = "M2获取成果等级转量化得分")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ObtainQuantitativeScoreForAchievementLevelCalcRespDto obtainQuantitativeScoreForAchievementLevelCalc(ObtainQuantitativeScoreForAchievementLevelCalcReqDto reqDto) {
         ObtainQuantitativeScoreForAchievementLevelCalcRespDto retData = new ObtainQuantitativeScoreForAchievementLevelCalcRespDto();
         Map<String,Double> infoIndex = new HashMap<>();
         for(DataSetsListOneDto dataOne : reqDto.getDataSetsListOne()){
             infoIndex.put(dataOne.getCustomField1(),dataOne.getComFloatField1());
         }
         BigDecimal sum = new BigDecimal("0");
         for(String one : reqDto.getDataSetsListTwo()){
             if(infoIndex.containsKey(one)){
                 Double value = infoIndex.get(one);
                 sum = sum.add(new BigDecimal(value));
             }
         }
         retData.setDataResult(sum.doubleValue());
        return retData;
      }
/**
      * code:receptionService
      * name:M2接收出参字段
      * desc:undefined
      * gen by moon at 4/25/2024, 1:49:00 PM
      *
      **/
     @Trace(operationName = "M2接收出参字段")
     @Tags({@Tag(key = "参数",value = "arg[0]"),
     @Tag(key = "返回值",value = "returnedObj")})
      public ImplementTenReceivingFieldRespDto implementTenReceivingField(ImplementTenReceivingFieldReqDto reqDto) {
         return BeanUtil.toBean(reqDto,ImplementTenReceivingFieldRespDto.class);
      }
  //手工接入方法
}
